package com.wwh.tx.homework;

import com.wwh.tx.homework.dao.BuyerDAO;
import com.wwh.tx.homework.dao.GoodDAO;
import com.wwh.tx.homework.dao.TaobaoDAO;
import com.wwh.tx.homework.service.ShopService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Albert
 * @date 2024/8/29-15:34
 * @describe
 */
public class Test {
    @org.junit.jupiter.api.Test
    public void testDAO() {
        ApplicationContext ioc = new ClassPathXmlApplicationContext("shopping_ioc.xml");

        GoodDAO goodDAO = ioc.getBean(GoodDAO.class);
        //System.out.println(goodDAO.queryPriceById(1));
        //goodDAO.updateStock(1, 30);
        System.out.println(goodDAO.querySellerIdById(1));

        //SellerDAO sellerDAO = ioc.getBean(SellerDAO.class);
        //sellerDAO.updateMoney(1, 300);

        //BuyerDAO buyerDAO = ioc.getBean(BuyerDAO.class);
        //buyerDAO.updateMoney(1, 1);

        //TaobaoDAO taobaoDAO = ioc.getBean(TaobaoDAO.class);
        //taobaoDAO.updateMoney(100);
    }

    @org.junit.jupiter.api.Test
    public void testService(){
        ApplicationContext ioc = new ClassPathXmlApplicationContext("shopping_ioc.xml");

        ShopService shopService = ioc.getBean(ShopService.class);
        shopService.buy(1,1,1);
    }
}
